const fs = require('fs');
const path = require('path');

// SVG 图标模板
const svgIcons = {
  home: {
    normal: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M10 20V14H14V20H19V12H22L12 3L2 12H5V20H10Z" fill="#94a3b8"/>
    </svg>`,
    active: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M10 20V14H14V20H19V12H22L12 3L2 12H5V20H10Z" fill="#6366f1"/>
    </svg>`
  },
  projects: {
    normal: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M20 6H16L14 4H10L8 6H4C2.9 6 2 6.9 2 8V19C2 20.1 2.9 21 4 21H20C21.1 21 22 20.1 22 19V8C22 6.9 21.1 6 20 6ZM20 19H4V8H20V19Z" fill="#94a3b8"/>
      <path d="M12 10C10.34 10 9 11.34 9 13S10.34 16 12 16S15 14.66 15 13S13.66 10 12 10Z" fill="#94a3b8"/>
    </svg>`,
    active: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M20 6H16L14 4H10L8 6H4C2.9 6 2 6.9 2 8V19C2 20.1 2.9 21 4 21H20C21.1 21 22 20.1 22 19V8C22 6.9 21.1 6 20 6ZM20 19H4V8H20V19Z" fill="#6366f1"/>
      <path d="M12 10C10.34 10 9 11.34 9 13S10.34 16 12 16S15 14.66 15 13S13.66 10 12 10Z" fill="#6366f1"/>
    </svg>`
  },
  profile: {
    normal: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 12C14.21 12 16 10.21 16 8S14.21 4 12 4S8 5.79 8 8S9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z" fill="#94a3b8"/>
    </svg>`,
    active: `<svg width="48" height="48" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 12C14.21 12 16 10.21 16 8S14.21 4 12 4S8 5.79 8 8S9.79 12 12 12ZM12 14C9.33 14 4 15.34 4 18V20H20V18C20 15.34 14.67 14 12 14Z" fill="#6366f1"/>
    </svg>`
  }
};

// 创建目录
const iconsDir = path.join(__dirname, 'src', 'static', 'icons');
if (!fs.existsSync(iconsDir)) {
  fs.mkdirSync(iconsDir, { recursive: true });
}

// 生成 SVG 文件
Object.keys(svgIcons).forEach(iconName => {
  // 普通状态
  const normalSvgPath = path.join(iconsDir, `${iconName}.svg`);
  fs.writeFileSync(normalSvgPath, svgIcons[iconName].normal);
  
  // 激活状态
  const activeSvgPath = path.join(iconsDir, `${iconName}-active.svg`);
  fs.writeFileSync(activeSvgPath, svgIcons[iconName].active);
  
  console.log(`✅ Generated ${iconName}.svg and ${iconName}-active.svg`);
});

console.log('\n🎉 所有 SVG 图标已生成完成！');
console.log('\n📝 接下来的步骤：');
console.log('1. 如果您需要 PNG 格式，可以使用以下方法转换：');
console.log('   - 在线工具：https://convertio.co/svg-png/');
console.log('   - 或使用 ImageMagick: convert icon.svg icon.png');
console.log('   - 或使用设计软件如 Figma、Sketch 等导出');
console.log('\n2. 建议的图标尺寸：');
console.log('   - 普通屏幕：48x48px');
console.log('   - 高清屏幕：96x96px');
console.log('   - 超高清屏幕：144x144px');